package com.mor.customer.controller;

import com.mor.customer.dto.CustomerDto;
import com.mor.customer.service.CustomerServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by dell on 2018/3/15.
 */
@Controller
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    private CustomerServiceImpl customerService;

    /**
     * 用户信息查询
     * @param request
     * @param dto
     * @return
     */
    @RequestMapping(value = "/findAllUser")
    public ModelAndView findAllUser_method(HttpServletRequest request,CustomerDto dto){
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("userList",customerService.findAllUser(dto));
        modelAndView.setViewName("customer/user");
        return modelAndView;
    }
    /**
     * 用户信息查询
     * @param request
     * @param dto
     * @return
     */
    @RequestMapping(value = "/findMyUser")
    @ResponseBody
    public Map<String,Object> findMyUser_method(HttpServletRequest request, CustomerDto dto){
        Map<String,Object> map=new HashMap<>();
        map.put("user",customerService.findAllUser(dto).get(0));
        return map;
    }

}
